package com.szholly.pro.watergas_server.ps.android.service;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;

import com.szholly.pro.watergas_server.ps.monitor.MonitorDataFormater;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.szholly.pro.watergas_server.common.data.DataUtil;
import com.szholly.pro.watergas_server.ps.android.bean.RuntimeDataBean;
import com.szholly.pro.watergas_server.ps.android.common.DateTime;
import com.szholly.pro.watergas_server.ps.android.common.NonNullUtil;
import com.szholly.pro.watergas_server.ps.android.common.NumUtils;
import com.szholly.pro.watergas_server.ps.android.common.ValidUtils;
import com.szholly.pro.watergas_server.ps.android.controller.SewageController;
import com.szholly.pro.watergas_server.ps.android.controller.SewageService;
import com.szholly.pro.watergas_server.ps.service.RemoteService;
import com.szholly.utils.util.StringUtils;
import com.szholly.data.general.GlobalParameter;
import com.szholly.data.general.RowBase;

@Service
public class MoveDataZhService {
	private final SewageService mSewageService = SewageController.getSewageManager();
	private final MonitorDataFormater mFormater = MonitorDataFormater.getInstance();
	private final static String FACTORY_PREFIX = "ZH";
	private static final List<String> PARAMETER_LIST = Arrays.asList("101", "001", "ss_zhuodu", "do");	
	// 获取所有的工厂字典信息--组编号为空则获取全部数据
	public List<RowBase> getFactoryList(String userId) throws Exception {
		ValidUtils.hasText(userId, "用户编号为空，工厂列表获取失败");
		List<GlobalParameter> parms = new ArrayList<>();
		parms.add(new GlobalParameter("userId", userId));
		parms.add(new GlobalParameter("prefix", FACTORY_PREFIX));

		String sql = "select distinct @prefix || t1.CODE \"id\",\n"
				+ "                t1.NAME \"name\",\n"
				+ "                n'暂无' \"mobile\",\n"
				+ "                n'暂无' \"address\",\n"
				+ "                n'暂无' \"legalPerson\",\n"
				+ "                '' \"imgUrl\",\n"
				+ "                t2.S_DOMAINCAPTION \"unit\"\n"
				+ "  from BC_SITE_INFO t1\n"
				+ "  left join (select s_id, S_DOMAINCAPTION\n"
				+ "               from DATA_DEFULATDOMAIN\n"
				+ "              where S_DOMAINNAME = '政区'\n"
				+ "                and length(s_id) = '2') t2\n"
				+ "    ON SUBSTR(t1.CODE, 3, 2) = t2.s_id\n"
				+ "  left join STATION_INFO t3\n"
				+ "    on t3.STATION_CODE = t1.CODE\n"
				+ "  left join OPERATION_GROUP_STATION_ASSO t4\n"
				+ "    on t4.station_id = t1.code\n"
				+ " where 1 = 1 and t1.code in (select distinct t.station_code\n"
				+ "          from OC_ROLE_SITE_PRIVILEGE t\n"
				+ "         inner join safe_userrole t1\n"
				+ "            on t1.s_userid =\n"
				+ "               @userId\n"
				+ "           and t.role_id = t1.s_roleid\n"
				+ "         where t.station_code is not null)";
		return NonNullUtil.toList(DataUtil.getSelectRows(sql, parms));
	}

	// 获取所有的站点字典信息
	public List<RowBase> getStationList(String userId) throws Exception {
		List<GlobalParameter> parms = new ArrayList<>();
		parms.add(new GlobalParameter("userId", userId));
		parms.add(new GlobalParameter("prefix", FACTORY_PREFIX));
		String sql = "select distinct t1.CODE \"id\",\n"
				+ "                t1.NAME \"name\",\n"
				+ "                t1.FLOW_TYPE \"flowType\",\n"
				+ "                t1.STATION_CATEGORY \"stationCategory\",\n"
				+ "                case\n"
				+ "                  when t1.station_category = '1' then\n"
				+ "                   @prefix || t1.CODE\n"
				+ "                  else\n"
				+ "                   t1.WWTP_ID\n"
				+ "                end \"factoryId\",\n"
				+ "                t2.S_DOMAINCAPTION \"unit\",\n"
				+ "                t1.x \"x\",\n"
				+ "                t1.y \"y\",\n"
				+ "                t1.x \"arcGisX\",\n"
				+ "                t1.Y \"arcGisY\"\n"
				+ "  from BC_SITE_INFO t1\n"
				+ "  left join (select s_id, S_DOMAINCAPTION\n"
				+ "               from DATA_DEFULATDOMAIN\n"
				+ "              where S_DOMAINNAME = '政区'\n"
				+ "                and length(s_id) = '2') t2\n"
				+ "    ON SUBSTR(t1.CODE, 3, 2) = t2.s_id\n"
				+ "  left join STATION_INFO t3\n"
				+ "    on t3.STATION_CODE = t1.CODE\n"
				+ "  left join OPERATION_GROUP_STATION_ASSO t4\n"
				+ "    on t4.station_id = t1.code\n"
				+ " where 1 = 1\n"
				+ "   and t1.code in (select distinct t.station_code\n"
				+ "                     from OC_ROLE_SITE_PRIVILEGE t\n"
				+ "                    inner join safe_userrole t1\n"
				+ "                       on t1.s_userid =\n"
				+ "                          @userId\n"
				+ "                      and t.role_id = t1.s_roleid\n"
				+ "                    where t.station_code is not null)";
		sql += " order by t2.S_DOMAINCAPTION";
		return NonNullUtil.toList(DataUtil.getSelectRows(sql, parms));
	}

	// 获取分区列表
	public List<RowBase> getAdministrativeDivisionList() throws Exception {
//		String sql = "select s_id \"id\", S_DOMAINCAPTION \"name\"\n"
//				+ "  from DATA_DEFULATDOMAIN\n"
//				+ " where S_DOMAINNAME = '政区'\n"
//				+ "   and length(s_id) = '2'\n"
//				+ " order by s_id";		
//		return NonNullUtil.toList(DataUtil.getSelectRows(sql, null));
		return new ArrayList<>();
	}

	// 获取所有的参数字典信息
	public List<RowBase> getParameterList() throws Exception {
		String sql = "select S_DOMAINCODE \"id\", S_DOMAINCAPTION \"name\", S_UNIT \"unit\"\n"
				+ "  from data_defulatdomain\n"
				+ " where S_DOMAINNAME = 'MONITOR_PARAM'";
		return NonNullUtil.toList(DataUtil.getSelectRows(sql, null));
	}

	public List<Map<String, Object>> getRuntimeData(String factoryCode) throws Exception {
		List<Map<String, Object>> valueList = new ArrayList<>();
		List<RowBase> rows = getDeviceList(factoryCode);
		ValidUtils.notEmpty(rows, "工厂编号有误，无法获取DeviceNumber");
		for (RowBase rowBase : rows) {
			String deviceNum = rowBase.getSafeString("DEVICE_NUM");
			String stationCode = rowBase.getSafeString("site_id");
			Map<String, Object> map = new HashMap<>();
			map.put("valueList", mSewageService.getRuntimeDataList(deviceNum));
			map.put("dateTime", mSewageService.getRuntimeDataTime(deviceNum));
			map.put("stationCode", stationCode);
			valueList.add(map);
		}
		return valueList;
	}

	/**
	 * 获取实时数据详情
	 * 
	 * 每个RowBase 包含以下信息
	 * 
	 * String leftLabel 左边的label
	 * 
	 * String rightLabel 右边的label
	 * 
	 * List<RuntimeDataBean> valueList 展示于界面上的数据
	 * 
	 * 包含两种数据(leftValue leftIsAlarm rightValue rightIsAlarm name)
	 */
	@SuppressWarnings("unchecked")
	public List<RowBase> getRuntimeDataDetail(String factoryCode) throws Exception {
		ValidUtils.hasText(factoryCode, "工厂编号为空，实时数据获取失败");
		// 返回的结果
		List<RowBase> resultList = new ArrayList<>();
		List<RowBase> deviceList = getDeviceList(factoryCode);
		RowBase result = null;
		String leftDateTime = null;
		for (int i = 0; i < deviceList.size(); i++) {
			RowBase deviceRow = deviceList.get(i);
			String deviceNum = deviceRow.getSafeString("DEVICE_NUM");
			String stationName = deviceRow.getSafeString("STATION_NAME");
			String label = stationName;

			// 实时数据
			List<Map<String, String>> runtimeDataList = mSewageService.getRuntimeDataList(deviceNum);
			// 实时数据对应的时间
			String dataTime = mSewageService.getRuntimeDataTime(deviceNum);

			boolean nowLeft = i % 2 == 0;
			Map<String, RuntimeDataBean> runtimeDataMap;
			if (nowLeft) {
				result = new RowBase();
				runtimeDataMap = new HashMap<>();
				result.put("leftLabel", label);
				result.put("valueList", runtimeDataMap);
				leftDateTime = dataTime;
				resultList.add(result);
				for (Map<String, String> value : runtimeDataList) {
					String parameterCode = value.get("id");
					RuntimeDataBean valueBean = new RuntimeDataBean();
					valueBean.setLeftValue(value.get("value"));
					valueBean.setLeftIsAlarm(value.get("isAlarm"));
					valueBean.setRightValue("-");
					valueBean.setRightIsAlarm("0");
					valueBean.setName(value.get("name"));
					runtimeDataMap.put(parameterCode, valueBean);
				}
			} else {
				runtimeDataMap = (Map<String, RuntimeDataBean>) result.get("valueList");
				result.put("rightLabel", label);
				for (Map<String, String> value : runtimeDataList) {
					String parameterCode = value.get("id");
					RuntimeDataBean valueBean;
					if (!runtimeDataMap.containsKey(parameterCode)) {
						valueBean = new RuntimeDataBean();
						valueBean.setLeftValue("-");
						valueBean.setLeftIsAlarm("0");
						valueBean.setName(value.get("name"));
						runtimeDataMap.put(parameterCode, valueBean);
					} else {
						valueBean = runtimeDataMap.get(parameterCode);
					}
					valueBean.setRightIsAlarm(value.get("isAlarm"));
					valueBean.setRightValue(value.get("value"));
				}
			}

			// 将Map转换成List
			if (!nowLeft || i == deviceList.size() - 1) {// 如果是右边或者是最后一个
				RuntimeDataBean dateTimeBean = new RuntimeDataBean();
				dateTimeBean.setName("数据时间");
				dateTimeBean.setLeftValue(leftDateTime);
				dateTimeBean.setLeftIsAlarm("0");

				List<RuntimeDataBean> valueList = new ArrayList<>(runtimeDataMap.values());
				if (!nowLeft) {// 右边
					dateTimeBean.setRightValue(dataTime);
					dateTimeBean.setRightIsAlarm("0");
				} else {
					dateTimeBean.setRightValue("-");
					dateTimeBean.setRightIsAlarm("0");
				}
				valueList.add(0, dateTimeBean);
				result.put("valueList", valueList);
			}
		}
		return resultList;
	}

	public List<Map<String, Object>> getHomeRuntimeDataList(String factoryCode) throws Exception {
		List<Map<String, Object>> valueList = new ArrayList<>();
		List<RowBase> rows = getDeviceList(factoryCode);
		for (RowBase rowBase : rows) {
			String deviceNum = rowBase.getSafeString("DEVICE_NUM");
			String stationCode = rowBase.getSafeString("site_id");
			SewageService manager = SewageController.getSewageManager();
			Map<String, Object> map = new HashMap<>();
			map.put("valueList", filterParameter(manager.getRuntimeDataList(deviceNum)));
			map.put("dateTime", manager.getRuntimeDataTime(deviceNum));
			map.put("stationCode", stationCode);
			valueList.add(map);
		}
		return valueList;
	}

	// 筛选出指定参数的数据
	public List<Map<String, String>> filterParameter(List<Map<String, String>> valueList) throws Exception {
		List<Map<String, String>> resultList = new ArrayList<>();
		if (!CollectionUtils.isEmpty(valueList)) {
			for (Map<String, String> bean : valueList) {
				String parameterCode = bean.get("id");
				if (PARAMETER_LIST.contains(parameterCode)) {
					resultList.add(bean);
				}
			}
		}
		return resultList;
	}

	// 获取设备信息
	public String factoryCode2StationCode(String factoryCode) throws Exception {
		return factoryCode.substring(FACTORY_PREFIX.length());
	}

	// 获取设备信息
	public List<RowBase> getDeviceList(String factoryCode) throws Exception {
		ValidUtils.hasText(factoryCode, "工厂编号为空，获取设备信息失败");
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		parms.add(new GlobalParameter("stationCode", factoryCode));
//		parms.add(new GlobalParameter("stationCode", factoryCode2StationCode(factoryCode)));
		String sql = "select t.DEVICE_NUM, t.site_id, t1.name station_name\n"
				+ "  from BC_COLLECTION_INFO t\n"
				+ "  left join BC_SITE_INFO t1\n"
				+ "    on t.site_id = t1.code\n"
				+ " where t.site_id = @stationCode";
		List<RowBase> rows = DataUtil.getSelectRows(sql, parms);
		return NonNullUtil.toList(rows);
	}
	/**
	 * 获取实时数据详情
	 * 
	 * 每个RowBase 包含以下信息
	 * 
	 * String leftLabel 左边的label
	 * 
	 * String rightLabel 右边的label
	 * 
	 * List<RuntimeDataBean> valueList 展示于界面上的数据
	 * 
	 * 包含两种数据(leftValue leftIsAlarm rightValue rightIsAlarm name)
	 */
	@SuppressWarnings("unchecked")
	public List<RowBase> getRuntimeDataDetail(List<RowBase> deviceList) throws Exception {
		// 返回的结果
		List<RowBase> resultList = new ArrayList<>();
		RowBase result = null;
		String leftDateTime = null;
		for (int i = 0; i < deviceList.size(); i++) {
			RowBase deviceRow = deviceList.get(i);
			String deviceNum = deviceRow.getSafeString("DEVICE_NUM");
			String stationName = deviceRow.getSafeString("STATION_NAME");

			String label = stationName;
			// if (isSurface) {
			// label = stationName;
			// } else {
			// int indexOf = stationName.indexOf("水口");
			// if (indexOf >= 1) {
			// label = stationName.substring(indexOf - 1, stationName.length());
			// }
			// }

			// 实时数据
			List<Map<String, String>> runtimeDataList = getRuntimeDataList(deviceNum);
			// 实时数据对应的时间
			String dataTime = getRuntimeDataTime(deviceNum);

			boolean nowLeft = i % 2 == 0;
			Map<String, RuntimeDataBean> runtimeDataMap;
			if (nowLeft) {
				result = new RowBase();
				runtimeDataMap = new HashMap<>();
				result.put("leftLabel", label);
				result.put("valueList", runtimeDataMap);
				leftDateTime = dataTime;
				resultList.add(result);			
				for (Map<String, String> value : runtimeDataList) {
					if(null != value.get("name") && value.get("name").toString().equals("累积流量")){
						continue;
					}		
					String parameterCode = value.get("id");
					RuntimeDataBean valueBean = new RuntimeDataBean();
					valueBean.setLeftValue(value.get("value"));
					//珠海不要报警
//					valueBean.setLeftIsAlarm("0");
					valueBean.setLeftIsAlarm(value.get("isAlarm"));
					valueBean.setRightValue("-");
					valueBean.setRightIsAlarm("0");
					valueBean.setName(value.get("name"));
					runtimeDataMap.put(parameterCode, valueBean);
				}
			} else {
				runtimeDataMap = (Map<String, RuntimeDataBean>) result.get("valueList");
				result.put("rightLabel", label);
				for (Map<String, String> value : runtimeDataList) {
					String parameterCode = value.get("id");
					RuntimeDataBean valueBean;
					if (!runtimeDataMap.containsKey(parameterCode)) {
						valueBean = new RuntimeDataBean();
						valueBean.setLeftValue("-");
						valueBean.setLeftIsAlarm("0");
						valueBean.setName(value.get("name"));
						runtimeDataMap.put(parameterCode, valueBean);
					} else {
						valueBean = runtimeDataMap.get(parameterCode);
					}
					valueBean.setRightIsAlarm(value.get("isAlarm"));
					valueBean.setRightValue(value.get("value"));
				}
			}

			// 将Map转换成List
			if (!nowLeft || i == deviceList.size() - 1) {// 如果是右边或者是最后一个
				RuntimeDataBean dateTimeBean = new RuntimeDataBean();
				dateTimeBean.setName("数据时间");
				dateTimeBean.setLeftValue(leftDateTime);
				dateTimeBean.setLeftIsAlarm("0");

				List<RuntimeDataBean> valueList = new ArrayList<>(runtimeDataMap.values());
				if (!nowLeft) {// 右边
					dateTimeBean.setRightValue(dataTime);
					dateTimeBean.setRightIsAlarm("0");
				} else {
					dateTimeBean.setRightValue("-");
					dateTimeBean.setRightIsAlarm("0");
				}
				valueList.add(0, dateTimeBean);
				result.put("valueList", valueList);
			}
		}
		return resultList;
	}
	// 获取实时数据{id,name,value,isAlarm}
		public List<Map<String, String>> getRuntimeDataList(String deviceNum) throws Exception {
			HashMap<String, RowBase> dataMap = RemoteService.getStationRealTimeData(deviceNum);
			List<Map<String, String>> valueList = new ArrayList<Map<String, String>>();
			if (!CollectionUtils.isEmpty(dataMap)) {
				Iterator<Entry<String, RowBase>> iterator = dataMap.entrySet().iterator();
				while (iterator.hasNext()) {
					Entry<String, RowBase> next = iterator.next();
					RowBase rowBase = next.getValue();
					Map<String, String> beanMap = createRuntimeDataMap(rowBase);
					valueList.add(beanMap);
				}
			}
			return valueList;
		}
		// 获取当前实时数据的时间
		public String getRuntimeDataTime(String deviceNum) throws Exception {
			List<RowBase> dateTimeList = RemoteService.getInstance().getStationHouseData(deviceNum);
			return dateTimeList.get(0).getSafeString("DATATIME");
		}
		private Map<String, String> createRuntimeDataMap(RowBase rowBase) {
			Map<String, String> resultMap = new HashMap<String, String>();
			String unit = rowBase.getSafeString("UNIT");
			String valueStr = rowBase.getSafeString("MEAS");

			// 是否报警
			Double alarmUp = NumUtils.toDouble(rowBase.getSafeString("ALARMUP"), Double.MAX_VALUE);
			Double alarmDown = NumUtils.toDouble(rowBase.getSafeString("ALARMDOWN"), Double.MIN_VALUE);

			Double value = NumUtils.toDouble(valueStr, null);
			String isAlarm = "0";
			if (value != null && (value < alarmDown || value > alarmUp)) {
				isAlarm = "1";
			}
			resultMap.put("isAlarm", isAlarm);

			// 参数值(值+单位)并避免出现科学计数法
			String wholeValue = optWholeValue(valueStr);
			if (StringUtils.IsNullOrSpace(wholeValue)) {
				resultMap.put("value", "");
			} else if (StringUtils.IsNullOrSpace(unit)) {
				resultMap.put("value", wholeValue);
			} else {
				resultMap.put("value", wholeValue + unit);
			}
			// 参数名
			resultMap.put("name", rowBase.getSafeString("POLLNAME"));
			// 参数ID
			resultMap.put("id", (String) rowBase.get("POLL"));
			return resultMap;
		}
		// 返回完整的数值，防止出现科学计数法
		private String optWholeValue(String value) {
			if(value == null || value.contains("E")){
				return null;
			}
			//20170706修改 修改人wzj 下面这句不太理解修改为上面
//			if (value == null && !value.contains("E")) {
//				return value;
//			}
			Double optDouble = NumUtils.toDouble(value, null);
			if (optDouble == null) {
				return null;
			}
			if(optDouble < 0){
				return "<0";
			}
			DecimalFormat df = new DecimalFormat("#.00");
			return String.valueOf(Double.parseDouble(df.format(optDouble)));
		}
		public List<Map<String, Object>> getHomeRuntimeDataList(List<RowBase> rows) throws Exception {
			List<Map<String, Object>> valueList = new ArrayList<>();
			for (RowBase rowBase : rows) {
				String deviceNum = rowBase.getSafeString("DEVICE_NUM");
				String stationCode = rowBase.getSafeString("site_id");
				SewageService manager = SewageController.getSewageManager();
				Map<String, Object> map = new HashMap<>();
				map.put("valueList", filterParameter(manager.getRuntimeDataList(deviceNum)));
				map.put("dateTime", manager.getRuntimeDataTime(deviceNum));
				map.put("stationCode", stationCode);
				valueList.add(map);
			}
			return valueList;
		}
		//获取时间段内的历史数据
				public List<RowBase> getHistoryHourData(String stationCode, DateTime startTime,DateTime endTime)throws Exception{
					String startTimeStr = startTime.toString("yyyy-MM-dd");
					String endTimeStr = endTime.toString("yyyy-MM-dd");
					List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
					parms.add(new GlobalParameter("stationCode", stationCode));
					parms.add(new GlobalParameter("startTime", startTimeStr));
					parms.add(new GlobalParameter("endTime", endTimeStr));
					String sql ="select t.avg \"value\",\n" +
									"       t.parmname \"parameterCode\",\n" + 
									"       to_char(t.datatime, 'dd-hh24') \"time\"\n" + 
									"  from monitor_data_hour t\n" + 
									"  left join BC_COLLECTION_INFO t1\n" + 
									"    on t1.device_num = t.mn\n" + 
									" where t1.site_id = @stationCode\n" + 
									"    and t.datatime >= to_date(@startTime, 'yyyy-mm-dd')\n" + 
									"   and t.datatime < to_date(@endTime, 'yyyy-mm-dd')+1\n" + 
									" order by t.parmname, t.datatime";
					List<RowBase> rows = DataUtil.getSelectRows(sql, parms);
					rows = NonNullUtil.toList(rows);
					// 校验数值 如果不属于数值，则删除
							List<RowBase> resultRows = new ArrayList<RowBase>();
							for (RowBase rowBase : rows) {
								try {
									String parameterCode = String.valueOf(rowBase.get("parameterCode"));
									if(parameterCode.equals("B01TOTAL")||parameterCode.equals("CYG")){
										continue;
									}
									Object value = rowBase.get("value");
//									Integer time = Integer.valueOf(rowBase.get("time").toString());
									String formatValue = mFormater.NumPointFormat(parameterCode, value, "0");
									if (!StringUtils.IsNullOrSpace(formatValue)) {
										rowBase.put("value", formatValue);
										resultRows.add(rowBase);
									}
								} catch (Exception e) {

								}
							}
							return NonNullUtil.toList(resultRows);
				}
				// 获取一天的分钟数据 (value,parameterCode,time)
				public List<RowBase> getOneDayMinData(String stationCode, DateTime dateTime) throws Exception {
					ValidUtils.hasText(stationCode, "站点编号为空，无法获取一天的小时数据");
					ValidUtils.notNull(dateTime, "日期为空，无法获取一天的小时数据");
					String dateTimeStr = dateTime.toString("yyyy-MM-dd");
					List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
					parms.add(new GlobalParameter("stationCode", stationCode));
					parms.add(new GlobalParameter("dateTime", dateTimeStr));
					String sql = "select t.avg \"value\",\n"
							+ "       t.parmname \"parameterCode\",\n"
							+ "       to_char(t.datatime, 'hh24:mi') \"time\"\n"
							+ "  from monitor_data_min t\n"
							+ "  left join BC_COLLECTION_INFO t1\n"
							+ "    on t1.device_num = t.mn\n"
							+ " where t1.site_id = @stationCode\n"
							+ "   and t.datatime >= to_date(@dateTime, 'yyyy-mm-dd')\n"
							+ "   and t.datatime < to_date(@dateTime, 'yyyy-mm-dd')+1\n"
							+ " order by t.parmname, t.datatime";
					List<RowBase> rows = DataUtil.getSelectRows(sql, parms);
					rows = NonNullUtil.toList(rows);
					// 校验数值 如果不属于数值，则删除
					final Pattern pattern = Pattern.compile("[0-9]{2}:[0-9]{2}");
					List<RowBase> resultRows = new ArrayList<RowBase>();
					for (RowBase rowBase : rows) {
						try {
							String parameterCode = String.valueOf(rowBase.get("parameterCode"));
							//珠海没有累积流量
							if(parameterCode.equals("B01TOTAL")||parameterCode.equals("CYG")){
								continue;
							}
							Object value = rowBase.get("value");
							String time = rowBase.get("time").toString();
							String formatValue = mFormater.NumPointFormat(parameterCode, value, "0");
							if (pattern.matcher(time).matches() && !StringUtils.IsNullOrSpace(formatValue)) {
								rowBase.put("value", formatValue);
								resultRows.add(rowBase);
							}
						} catch (Exception e) {

						}
					}
					return NonNullUtil.toList(resultRows);
				}
}
